﻿#include "login.h"
#include "ui_login.h"

login::login(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::login)
{
    ui->setupUi(this);
    this->setAttribute(Qt::WA_DeleteOnClose);
}

login::~login()
{
    delete ui;
}

void login::on_login_P_clicked()
{
    emit socket_setpassword(ui->PassWord_L->text());
    emit socket_senddata(ui->ID_L->text(),"用户登陆",ui->PassWord_L->text());
    emit set_id_password(ui->ID_L->text(),ui->PassWord_L->text());
}

void login::on_pushButton_clicked()
{
    this->reject();
}

void login::setsocket(tcp_socket *socket)
{
    this->socket=socket;
}

void login::receive_data(QStringList data)
{
   if(data[1]=="用户登陆")
   {

       if(data[2]=="登陆成功")
       {
            qDebug()<<data;
            this->accept();
       }
       else
       {
           QMessageBox::about(NULL, "登陆失败", "账号密码错误!");
       }
   }
}
